using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test1 : MonoBehaviour
{
    public bool isTalking = false;
    public bool isTalked = false;
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (isTalked)
        {
            return;
        }
        print("1");
        collision.GetComponent<test1>().isTalked = true;
        StartCoroutine(Open(collision.GetComponent<test1>()));

    }

    IEnumerator Open(test1 test1)
    {
        yield return StartCoroutine(test());
        print("2");
        test1.isTalked = false;
    }

    IEnumerator test()
    {
        print("3");
        yield return new WaitForSeconds(3);
        print("3");
    }
}
